<?php
namespace Hilaoyu\ComputeCloudClient;


class AssetModel
{
    public $type = null;
    public $asset_id = null;
    public $name = null;
    public $instance_type = null;
    public $region_id = null;
    public $zone_id = null;
    public $cpu = null;
    public $memory = null;
    public $network = null;
    public $bandwidth = null;
    public $primary_ip = null;
    public $second_ip = null;
    public $public_ip = null;
    public $bind_asset_id = null;
    public $os_type = null;
    public $os = null;
    public $os_image = null;
    public $os_account = null;
    public $os_password = null;
    public $manage_password = null;
    public $status = null;
    public $owner_id = null;
    public $pay_change_type = null;

    public $vsw_vtb = null;
    public $cmd_content = null;

    public function toArray(bool $includeNull=false){
        $keys = [
            'asset_id',
            'type',
            'name',
            'instance_type',
            'region_id',
            'zone_id',
            'cpu',
            'memory',
            'network',
            'bandwidth',
            'primary_ip',
            'second_ip',
            'public_ip',
            'bind_asset_id',
            'os_type',
            'os',
            'os_image',
            'os_account',
            'os_password',
            'manage_password',
            'vsw_vtb',
            'cmd_content',
            'owner_id',
            'pay_change_type',
            'status',
        ];

        $res = [];
        foreach ($keys as $key){
            $v = $this->{$key};
            if(!$includeNull && is_null($v)){
                continue;
            }
            $res[$key] = $v;
        }

        return $res;
    }

    public function merge(self $model){
        foreach ( $model->toArray(false) as $key =>$value){
            $this->{$key} = $value;
        }
        return $this;
    }
}
